<%@ page language="java" import="java.util.*,entity.*,biz.*,biz.impl.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	request.setCharacterEncoding("GBK");
	String title = request.getParameter("title");	//取得帖子的标题
	String content = request.getParameter("content");//取得帖子的内容
	
	TopicBiz topicBiz = new TopicBizImpl();
	/*TopicDao topicDao = new TopicDaoImpl();	//得到主题Dao的实例*/
	User user = (User)session.getAttribute("user");//从session中取得登录用户
	int boardId = Integer.parseInt(request.getParameter("boradId"));//取得板块ID
	
	if(user!=null){
		Topic topic = new Topic();
		topic.setTitle(title);
		topic.setContent(content);
		topic.setBoardId(boardId);
		topic.setUserId(user.getUserId());
		//发表时间和修改时间将由Dao类生成
		topicBiz.addTopic(topic);//保存主题帖子
		response.sendRedirect("../list.jsp?page=1&boardId=" + boardId);//跳转到列表页
	}else{
		response.sendRedirect("../login.jsp");//跳转到登录页
	}
	
/* 	int boardId = 9;//板块ID固定
	
	Topic topic = new Topic();
	topic.setTitle(title);
	topic.setContent(content);
	topic.setBoardId(boardId);
	topic.setUserId(1);		//发帖用户固定
	
	//发表时间和修改时间将由Dao类生成
	
	topicDao.addTopic(topic);	//保存主题帖子
	response.sendRedirect("../list.jsp");//跳转 */
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>doPost</title>
  </head>
  
  <body>
  </body>
</html>
